package com.fms.gui.emailer.components;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.fms.model.factory.parts.IFileNameSupplier;

public class FlowSheetSelection extends JPanel implements ActionListener, ITextSupplier
{
	private JTextField selectedText;

	private IFileNameSupplier	selector; 
	
	private static final long	serialVersionUID	= -1913271864524936894L;

	public FlowSheetSelection(IFileNameSupplier _selector)
	{
		this.selector = _selector;
		this.setLayout(new BorderLayout());
		JButton select = new JButton();
		select.setText("Select Sheet");
		select.addActionListener(this);
		this.add(select, BorderLayout.EAST);
		
		selectedText = new JTextField();
		this.add(selectedText, BorderLayout.CENTER);
		
		
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0)
	{
		selectedText.setText(selector.getFile());		
	}

	@Override
	public String getText()
	{
		return selectedText.getText();
	}

	@Override
	public void setText(String text)
	{
		selectedText.setText(text);
	}
}
